Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.initPieChart = initPieChart, exports.initBarChart = initBarChart, exports.initLineChart = initLineChart;

var echarts = _interopRequireWildcard(require("../../libs/ec-canvas/echarts")), _echartsActions = require("./echarts-actions");

function _interopRequireWildcard(e) {
    if (e && e.__esModule) return e;
    var t = {};
    if (null != e) for (var r in e) if (Object.prototype.hasOwnProperty.call(e, r)) {
        var i = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(e, r) : {};
        i.get || i.set ? Object.defineProperty(t, r, i) : t[r] = e[r];
    }
    return t.default = e, t;
}

function _objectSpread(t) {
    for (var e = 1; e < arguments.length; e++) {
        var r = null != arguments[e] ? arguments[e] : {}, i = Object.keys(r);
        "function" == typeof Object.getOwnPropertySymbols && (i = i.concat(Object.getOwnPropertySymbols(r).filter(function(e) {
            return Object.getOwnPropertyDescriptor(r, e).enumerable;
        }))), i.forEach(function(e) {
            _defineProperty(t, e, r[e]);
        });
    }
    return t;
}

function _defineProperty(e, t, r) {
    return t in e ? Object.defineProperty(e, t, {
        value: r,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[t] = r, e;
}

function setChart(e, t, r, i) {
    var o = echarts.init(e, null, {
        width: t,
        height: r
    });
    return e.setChart(o), o.setOption(i), o;
}

function initPieChart(i) {
    var e = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : "interest", t = _echartsActions.pieChartType[e], o = t.config;
    return (0, t.handle)(i, o), function(e, t, r) {
        return setChart(e, t, r, _objectSpread({
            animation: !1,
            title: _objectSpread({
                text: "客户兴趣占比",
                left: 18,
                top: 10,
                textStyle: {
                    fontSize: "16"
                }
            }, o.title),
            legend: _objectSpread({
                left: "center",
                bottom: "4%",
                itemWidth: 14,
                itemHiehgt: 10,
                selectedMode: !1,
                data: [ "对成员感兴趣", "对产品感兴趣", "对公司感兴趣" ]
            }, o.legend),
            backgroundColor: "#ffffff",
            color: [ "#f9bd00", "#3bbb00", "#41afff" ],
            series: [ _objectSpread({
                label: {
                    normal: _objectSpread({
                        fontSize: 17,
                        formatter: "{c}%"
                    }, o.labelNormal)
                },
                type: "pie",
                center: [ "50%", "52%" ],
                radius: [ "30%", "48%" ],
                data: [ {
                    value: i.viewmemberrate,
                    name: "对成员感兴趣"
                }, {
                    value: i.viewproductrate,
                    name: "对产品感兴趣"
                }, {
                    value: i.viewsiterate,
                    name: "对公司感兴趣"
                } ]
            }, o.series) ]
        }, o.option));
    };
}

function initBarChart(e) {
    var t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : "interact", r = _echartsActions.barChartType[t], i = r.config, o = (0, 
    r.handle)(e, i);
    return function(e, t, r) {
        return setChart(e, t, r, {
            animation: !1,
            title: _objectSpread({
                text: "客户互动情况",
                left: 18,
                top: 10,
                textStyle: {
                    fontSize: "16"
                }
            }, i.title),
            backgroundColor: "#ffffff",
            color: [ "#37a2da", "#32c5e9", "#67e0e3" ],
            grid: _objectSpread({
                left: 25,
                right: 25,
                bottom: 20,
                top: 52,
                containLabel: !0
            }, i.grid),
            xAxis: [ {
                type: "value",
                axisLine: {
                    lineStyle: {
                        color: "#cccccc"
                    }
                },
                axisLabel: {
                    color: "#888888"
                },
                splitLine: {
                    show: !1
                }
            } ],
            yAxis: [ _objectSpread({
                type: "category",
                axisTick: {
                    show: !1
                },
                data: [ "拨打电话", "转发名片", "保存电话", "沟通联系", "点赞名片" ],
                axisLine: {
                    lineStyle: {
                        color: "#cccccc"
                    }
                },
                axisLabel: {
                    color: "#888888"
                }
            }, i.yAxis) ],
            series: [ {
                type: "bar",
                label: {
                    normal: _objectSpread({
                        show: !0,
                        position: "right"
                    }, i.labelNormal)
                },
                barWidth: 15,
                data: o,
                itemStyle: {
                    color: "#50c74e",
                    barBorderRadius: [ 0, 3, 3, 0 ]
                }
            } ]
        });
    };
}

function initLineChart(e) {
    var t = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : "tendency", i = _echartsActions.lineChartType[t].config, r = [];
    e.filter(function(e) {
        return "0" !== e.count;
    }).length ? e.forEach(function(e) {
        0 === r.length && "0" === e.count || r.push(e);
    }) : r = e;
    var o = r.map(function(e) {
        return e.date;
    }), a = r.map(function(e) {
        return e.count;
    });
    return function(e, t, r) {
        return setChart(e, t, r, {
            animation: !1,
            title: _objectSpread({
                text: "",
                left: 18,
                top: 10,
                show: !1,
                textStyle: {
                    fontSize: "16"
                }
            }, i.title),
            backgroundColor: "#fff",
            color: [ "#50c74e" ],
            tooltip: {
                trigger: "axis"
            },
            grid: _objectSpread({
                left: "3%",
                right: "4%",
                top: "3%",
                bottom: "3%",
                containLabel: !0
            }, i.grid),
            xAxis: {
                type: "category",
                data: o,
                axisLine: {
                    show: !1
                },
                axisTick: {
                    show: !1
                },
                axisLabel: {
                    color: "#888888"
                }
            },
            yAxis: {
                x: "center",
                type: "value",
                axisLine: {
                    show: !1
                },
                axisTick: {
                    show: !1
                },
                axisLabel: {
                    color: "#888888"
                }
            },
            series: [ {
                name: "A商品",
                type: "line",
                smooth: !1,
                symbol: "circle",
                symbolSize: "6",
                data: a,
                lineStyle: {
                    color: "#50c74e"
                },
                areaStyle: {
                    normal: {
                        color: {
                            type: "linear",
                            x: 0,
                            y: 0,
                            x2: 0,
                            y2: 1,
                            colorStops: [ {
                                offset: 0,
                                color: "rgba(80, 199, 78, 0.2)"
                            }, {
                                offset: 1,
                                color: "rgba(255, 255, 255, 0)"
                            } ]
                        }
                    }
                }
            } ]
        });
    };
}